package com.example.pattern.draw.shape

import android.graphics.Canvas
import android.graphics.Paint

class StraightLine:Shape(){
    override fun containsPoint(x: Float, y: Float): Boolean {
        val slop = (endPoint.y-startPoint.y)/(endPoint.x-startPoint.x)
        val distance = startPoint.y - slop*startPoint.x
        return y == slop*x+distance
    }

    override fun drawShape(canvas: Canvas) {
        mPaint.strokeJoin = Paint.Join.ROUND
        canvas.drawLine(startPoint.x,startPoint.y,endPoint.x,endPoint.y,mPaint)
    }
}